package de.idgard.android.service;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.view.Gravity;
import android.widget.Toast;
import de.idgard.android.R;
import de.idgard.android.addon.services.GlobalServiceRegistry;
import de.idgard.android.addon.ui.AddonUIManager;

public class ConnectionChangeReceiver extends BroadcastReceiver {
	@Override
	public void onReceive(Context context, Intent intent) {
		
		GlobalServiceRegistry.instance().init(context);
		if (!GlobalServiceRegistry.instance().getAddonStateService()
				.isAddonON()) {
			return;
		}

		if (!AddonUIManager.getInstance().isOnline(context)) {
			Toast toast = Toast.makeText(context,
					R.string.dialog_alert_desc_no_network, Toast.LENGTH_LONG);
			toast.show();
		} else {
			Toast toast = Toast.makeText(context, R.string.has_network,
					Toast.LENGTH_LONG);
			toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
			toast.show();
		}
	}
}
